package com.jl.jlapp.mvp.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import com.jl.jlapp.R;
import com.jl.jlapp.eneity.MessageNoReadNumModel;
import com.jl.jlapp.eneity.Order;
import com.jl.jlapp.mvp.fragment.MyOrderListFragment;
import com.jl.jlapp.mvp.fragment.NotFoundOrderListFragment;
import com.jl.jlapp.nets.Api;
import com.jl.jlapp.nets.CommonObserver;
import com.jl.jlapp.nets.Net;
import com.jl.jlapp.nets.Transformer;

import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

import java.util.ArrayList;

public class MyOrderListActivity extends FragmentActivity implements OnCheckedChangeListener, OnClickListener {
    FragmentManager fragmentManager;
    @BindView(R.id.message)
    ImageView message;
    Fragment myOrderListFragment;
    @BindView(R.id.my_order_state_radiogroup)
    RadioGroup myOrderStateRadiogroup;
    Fragment notFoundOrderListFragment;
    ArrayList<Order> orderList;
    public int orderState = -1;
    @BindView(R.id.my_order_state_all)
    RadioButton rbAll;
    @BindView(R.id.my_order_state_for_the_goods)
    RadioButton rbForTheGoods;
    @BindView(R.id.my_order_state_for_the_payment)
    RadioButton rbForThePayment;
    @BindView(R.id.my_order_state_has_been_completed)
    RadioButton rbHasBeenBompleted;
    @BindView(R.id.my_order_state_in_the_after_sale)
    RadioButton rbInTheAfterSale;
    FragmentTransaction transaction;
    int userId = 0;

    public void getMessageNum(Integer paramInteger) {
        Net.get().getMessageNum(paramInteger.intValue())
                .compose(Transformer.<MessageNoReadNumModel>switchSchedulers())
                .subscribe(new CommonObserver<MessageNoReadNumModel>() {
                    @Override
                    protected void onError(String errorMsg) {

                    }

                    @Override
                    protected void onSuccess(MessageNoReadNumModel messageNoReadNumModel) {

                    }
                });
    }

    public void onCheckedChanged(RadioGroup paramRadioGroup, int paramInt) {
        Drawable drawable = getResources().getDrawable(R.drawable.checkeed_line);
        switch (paramInt) {
            case R.id.my_order_state_all:
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(-1);
                return;
            case R.id.my_order_state_for_the_payment:
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(0);
                return;
            case R.id.my_order_state_for_the_goods:
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(2);
                return;
            case R.id.my_order_state_has_been_completed:
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(3);
                return;
        }
        this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
        replaceFragmentByOrderState(6);
    }

    @OnClick({R.id.order_list_return, R.id.message})
    public void onClick(View paramView) {
        switch (paramView.getId()) {
            case R.id.order_list_return:
                finish();
                return;
        }
        startActivity(new Intent(this, MessageCenterActivity.class));
    }

    protected void onCreate(Bundle paramBundle) {
        super.onCreate(paramBundle);
        setContentView(R.layout.activity_my_order_list);
        ButterKnife.bind(this);
        this.orderState = getIntent().getIntExtra("orderState", -1);
        this.userId = getSharedPreferences("JLAppData", 0).getInt("userId", 0);
        setDateToControl();
        setClickListener();
        getMessageNum(Integer.valueOf(this.userId));
        this.fragmentManager = getSupportFragmentManager();
        Drawable drawable = getResources().getDrawable(R.drawable.checkeed_line);
        switch (this.orderState) {
            case -1:
                this.rbAll.setChecked(true);
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(-1);
                return;
            case 0:
                this.rbForThePayment.setChecked(true);
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(0);
                return;
            case 2:
                this.rbForTheGoods.setChecked(true);
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(2);
                return;
            case 3:
                this.rbHasBeenBompleted.setChecked(true);
                this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
                this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
                replaceFragmentByOrderState(3);
                return;
        }
        this.rbInTheAfterSale.setChecked(true);
        this.rbAll.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbForTheGoods.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbForThePayment.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbHasBeenBompleted.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
        this.rbInTheAfterSale.setCompoundDrawablesWithIntrinsicBounds(null, null, null, drawable);
        replaceFragmentByOrderState(6);
    }

    public void replaceFragmentByOrderState(int paramInt) {
        this.orderState = paramInt;
        this.transaction = this.fragmentManager.beginTransaction();
        this.myOrderListFragment = new MyOrderListFragment();
        this.transaction.replace(R.id.my_order_list_fragment, this.myOrderListFragment);
        this.transaction.commit();
    }

    public void replaceIfNoData() {
        this.transaction = this.fragmentManager.beginTransaction();
        if (this.notFoundOrderListFragment == null) {
            this.notFoundOrderListFragment = new NotFoundOrderListFragment();
        }
        this.transaction.replace(R.id.my_order_list_fragment, this.notFoundOrderListFragment);
        this.transaction.commit();
    }

    public void setClickListener() {
        this.myOrderStateRadiogroup.setOnCheckedChangeListener(this);
    }

    public void setDateToControl() {
        this.rbAll.setChecked(true);
    }
}


/* Location:              /Users/davidzhang/Documents/decompileApk/jlfood-dex2jar.jar!/com/jl/jlapp/mvp/activity/MyOrderListActivity.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */